#include "integer.h"

Integer::Integer(int val) : NonComplexNumber(INTEGER){
        this->val = val;
        this->type = INTEGER;
}

Constante* Integer::operator+(const Constante& c)const{

        switch(c.getType()){
                case Constante::INTEGER:
        return new Integer(this->val + static_cast<const Integer&>(c).val);
                break;
        }
}

Constante* Integer::operator*(const Constante& c)const{
        switch(c.getType()){
                case Constante::INTEGER:
        return new Integer(this->val * static_cast<const Integer&>(c).val);
                break;
        }
}

Constante* Integer::operator-(const Constante& c)const{
        switch(c.getType()){
                case Constante::INTEGER:
        return new Integer(this->val - static_cast<const Integer&>(c).val);
                break;
        }

}

Constante* Integer::operator/(const Constante& c)const{
        switch(c.getType()){
                case Constante::INTEGER:
        return new Integer(this->val / static_cast<const Integer&>(c).val);//donne le bon résultat?
        return 0;
                break;
        }

}

Constante* Integer::operator%(const Constante& c)const{
   switch(c.getType()){
       case Constante::INTEGER:
        return new Integer(val % static_cast<const Integer&>(c).val);
   }
}
Constante* Integer::operator!()const{
    int tmp=1;
    for(int i=0;i<val-1;i++)
        tmp*=val-i;
    return new Integer(tmp);
}

Constante* Integer::operator-()const{
        return new Integer(-this->val);
}
